﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Windows;
using System.Diagnostics;

[assembly: CLSCompliant(true)]
namespace YSCommander
{
	/// <summary>
	/// Interaction logic for App.xaml
	/// </summary>
	public partial class App : Application
	{

		[STAThread]
		static void Main()
		{
			System.Threading.Mutex mutex = new System.Threading.Mutex(false, "YSCommander mutex");

			if (!mutex.WaitOne(0, false))
			{
				MessageBox.Show("Another instance is already running.",
						"YSCommander", MessageBoxButton.OK, MessageBoxImage.Exclamation);
			}
			else
			{
				App app = new App();
				app.InitializeComponent();
				try
				{
					app.Run();
				}
				catch (Exception excp)
				{
					MessageBox.Show(String.Format("Sorry, got exception: {0}", excp.ToString()),
						"YSCommander", MessageBoxButton.OK, MessageBoxImage.Exclamation);
				}
				finally
				{
					mutex.ReleaseMutex();
				}
			}
		}
	}
}
